<?php
/**
 * @filesource:					DeadModel.class.php
 * @desc:						逝者模块类
 * 
 * @author:						shenyaqing
 * @copyright:					hou.yining@gmail.com
 * @date:						2011-04-20
 */

class DeadModel extends Model{
	protected $_map = array(
	);
	
	protected $_validate = array(
		array('type_id','require', '逝者类型必须！'),
		//array('graveyard_id','require','墓地必须！'), 
		//array('charge_person_id', 'require', '主办人必须！'),
		array('dead_number', 'require', '死亡证编号必须！'),
		array('name', 'require', '寄存人姓名必须！'),
		array('gender', 'require', '寄存人性别必须！'),
		array('age', 'require', '寄存人年龄必须！'),
		array('born_time', 'require', '出生日期必须！'),
		array('dead_time', 'require', '死亡日期必须！'),
		array('relations_with_charge_person', 'require', '与主办人关系必须！'),
	);
	protected $_auto = array ( 
		array('creater_time', 'time', MODEL::MODEL_BOTH, 'function'),
		array('creater_id', 'get_current_operator', MODEL::MODEL_BOTH, 'function'),
		array('creater_name', 'get_current_operator_name', MODEL::MODEL_BOTH, 'function'),
		
	);
	public function getDeadInfo($deposit_id){
		import("ORG.Util.Page"); 
        //取得满足条件的记录数
        $count = $this->where('type_id='.$deposit_id)->count();

        $page = new Page($count, 5);
        $show = $page->show();
		$rs = $this->query("SELECT DISTINCT d . * , g.name charge_person_name FROM GMS_dead d, GMS_general_customer g WHERE d.charge_person_id = g.id AND d.type_id ='$deposit_id' order by id desc limit ".$page->firstRow.','.$page->listRows."");
	  
	    $arr['show'] = $show;
	    $arr['rs'] = $rs;
        return $arr;
	}
	public function getDieInfo($id){
		$vo = $this->table('GMS_dead d,GMS_general_customer g')->where("d.charge_person_id=g.id and d.id='$id'")->field('d.*,g.name charge_person_name,g.sex,g.age customer_age,g.grade,g.telephone,g.email,g.fax,g.company,g.job work,g.identity_id,g.other,g.education,g.remark customer_remark,g.relations_with_dead,g.province customer_province,g.city customer_city,g.area,g.address customer_address')->select();
		return $vo;
	}
	public function getDieInfo2($where){
		$result = $this->table("GMS_dead d,GMS_general_customer g,GMS_hold_state s")->where("d.charge_person_id=g.id and d.disposit_state=s.id and d.name='$where'")->field("d.*,g.name charge_person_name,s.name deposit_status")->select();
		return $result;
	}
}
?>